import request from '@/utils/request'

// 查询生产工单列表
export function listWorkorder(query) {
  return request({
    url: '/workorder/workorder/enterList',
    method: 'get',
    params: query
  })
}

//查询近一周的工单列表
export function listWorkorderWeek() {
  return request({
    url: '/workorder/workorder/listWorkorderWeek',
    method: 'get'
  })
}

// 查询生产工单详细
export function getWorkorder(workorderId) {
  return request({
    url: '/workorder/workorder/' + workorderId,
    method: 'get'
  })
}

// 新增生产工单
export function addWorkorder(data) {
  return request({
    url: '/workorder/workorder',
    method: 'post',
    data: data
  })
}

// 修改生产工单
export function updateWorkorder(data) {
  return request({
    url: '/workorder/workorder',
    method: 'put',
    data: data
  })
}

// 删除生产工单
export function delWorkorder(workorderId) {
  return request({
    url: '/workorder/workorder/' + workorderId,
    method: 'delete'
  })
}

//查询产品BOM表
export function getListBom(productId) {
  return request({
    url: '/workorder/workorder/getBomById',
    method: 'get',
    params: { productId: productId }
  })
}


//批量插入工单中的BOM组成，往生产工单BOM组成表中插入
export function addWorkorderBom(data) {
  console.log(data);

  return request({
    url: '/workorder/workorder/addWorkorderBom',
    method: 'post',
    data: data
  })
}

//根据工单编码获取工单BOM组成
export function getWorkInnerBomList(workorderCode) {
  return request({
    url: '/workorder/workorder/getWorkInnerBomList',
    method: 'get',
    params: { workorderCode: workorderCode }
  })
}